package com.lloydfinch.mvvm;

import android.arch.lifecycle.ViewModelProvider;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.lloydfinch.mvvm.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {

    private MainUIController mainUIController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        mainUIController = new MainUIController(binding, new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(MainViewModel.class));
        mainUIController.attach(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mainUIController.detach(this);
    }
}